﻿Imports Telerik.Web.UI
Imports System.Data
Imports System.Data.SqlClient

Partial Class Supplier
    Inherits System.Web.UI.Page
    Dim _CommandName As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim _lblPageTitle As Label
            _lblPageTitle = Me.Master.FindControl("lblPageTitle")
            _lblPageTitle.Text = GetLocalResourceObject("PageTitle")
        End If
    End Sub

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Me.Theme = GetGlobalResourceObject("SystemResource", "Theme")
    End Sub


    Public Sub FillBankAccounts(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
        hdnBankID.Value = e.Value
    End Sub

    Protected Sub rgSupplier_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles rgSupplier.ItemCommand
        _CommandName = e.CommandName
    End Sub

    Protected Sub rgSupplier_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles rgSupplier.ItemDataBound
        If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) And _CommandName <> "InitInsert" Then
            'If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then

            Dim editFormItem As GridEditFormItem = CType(e.Item, GridEditFormItem)
            Dim parentItem As GridDataItem = editFormItem.ParentItem

            Dim box As RadComboBox = CType(editFormItem.FindControl("WUCBank").FindControl("rcbd"), RadComboBox)
            box.SelectedValue = parentItem("BankID").Text
            hdnBankID.Value = box.SelectedValue
            Dim box1 As RadComboBox = CType(editFormItem.FindControl("WUCBankAccountNo").FindControl("rcbd"), RadComboBox)
            box1.DataBind()
            box1.SelectedValue = parentItem("BankAccountsID").Text
        End If

    End Sub
End Class
